home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
pascal
/
stay42.zip
/
STAYSUBS.420
< prev
next >
Wrap
Text File
|
1986-08-06
|
17KB
|
401 lines
{****************************************************************************}
{ S T A Y S U B S . I N C }
{****************************************************************************}
{---------------------------------------------------------}
{ S E T U P I N T E R R U P T }
{---------------------------------------------------------}{
{ Msg # *48 Dated 07-07-86 16:54:36
From: NEIL RUBENKING
To: LANE FERRIS
Re: STAY, WON'T YOU?
Lane,
Here's what I did:
}
PROCEDURE Setup_Interrupt(IntNo :byte; VAR IntVec :vector; offset :integer);
BEGIN
Regs.Ax := $3500 + IntNo;
Intr(DosI21,Regs); {get the address of interrupt }
IntVec.IP := Regs.BX; { Location of Interrupt Ip }
IntVec.CS := Regs.Es; { Location of Interrupt Cs }
Regs.Ax := $2500 + IntNo; { set the interrupt to point to}
Regs.Ds := Cseg; { our procedure}
Regs.Dx := Offset;
Intr (DosI21,Regs);
END;
(******************* C O M M E N T *****************************************
{in the main part of the program}
Setup_Interrupt(BIOSI16, BIOS_Int16, Ofs(Stay_INT16)); {keyboard}
Setup_Interrupt(BIOSI10, BIOS_Int10, Ofs(Stay_INT10)); {video}
Setup_Interrupt(BIOSI8, BIOS_Int8, Ofs(Stay_INT8)); {timer}
Setup_Interrupt(BIOSI13, BIOS_Int13, Ofs(Stay_INT13)); {disk}
Setup_Interrupt(DOSI21, DOS_Int21, Ofs(Stay_INT21)); {DOSfunction}
Setup_Interrupt(DOSI28, DOS_Int28, Ofs(Stay_INT28)); {DOS idle}
********************* C O M M E N T *****************************************)
{---------------------------------------------------------}
{ S E T D T A }
{---------------------------------------------------------}
Procedure SetDTA(var segment, offset : integer );
BEGIN
regs.ax := $1A00; { Function used to get current DTA address }
regs.Ds := segment; { Segment of DTA returned by DOS }
regs.Dx := offset; { Offset of DTA returned }
MSDos( regs ); { Execute MSDos function request }
END;
{---------------------------------------------------------}
{ G E T D T A }
{---------------------------------------------------------}
Procedure GetDTA(var segment, offset : integer );
BEGIN
regs.ax := $2F00; { Function used to get current DTA address }
MSDos( regs ); { Execute MSDos function request }
segment := regs.ES; { Segment of DTA returned by DOS }
offset := regs.Bx; { Offset of DTA returned }
END;
{---------------------------------------------------------}
{ S E T P S P }
{---------------------------------------------------------}
Procedure SetPSP(var segment : integer );
BEGIN
{ A bug in DOS 2.0, 2.1, causes DOS to clobber its standard stack }
{ when the PSP get/set functions are issued at the DOS prompt. The }
{ following checks are made, forcing DOS to use the "critical" }
{ stack when the TSR enters at the INDOS level. }
{If Version less then 3.0 and INDOS set }
If DosVersion < 3 then { then set the Dos Critical Flag }
If Mem[DosStat1.CS:DosStat1.IP] <> 0 then
Mem[DosStat2.CS:DosStat2.IP] := $FF;
regs.ax := $5000; { Function to set current PSP address }
regs.bx := segment; { Segment of PSP to be used by DOS }
MSDos( regs ); { Execute MSDos function request }
{If Version less then 3.0 and INDOS set }
If DosVersion < 3 then { then clear the Dos Critical Flag }
If Mem[DosStat1.CS:DosStat1.IP] <> 0 then
Mem[DosStat2.CS:DosStat2.IP] := $00;
END;
{---------------------------------------------------------}
{ G E T P S P }
{---------------------------------------------------------}
Procedure GetPSP(var segment : integer );
BEGIN
{ A bug in DOS 2.0, 2.1, causes DOS to clobber its standard stack }
{ when the PSP get/set functions are issued at the DOS prompt. The }
{ following checks are made, forcing DOS to use the "critical" }
{ stack when the TSR enters at the INDOS level. }
{If Version less then 3.0 and INDOS set }
If DosVersion < 3 then { then set the Dos Critical Flag }
If Mem[DosStat1.CS:DosStat1.IP] <> 0 then
Mem[DosStat2.CS:DosStat2.IP] := $FF;
regs.ax := $5100; { Function to get current PSP address }
MSDos( regs ); { Execute MSDos function request }
segment := regs.Bx; { Segment of PSP returned by DOS }
{IF DOS Version less then 3.0 and INDOS set }
If DosVersion < 3 then { then clear the Dos Critical Flag }
If Mem[DosStat1.CS:DosStat1.IP] <> 0 then
Mem[DosStat2.CS:DosStat2.IP] := $00;
END;
{---------------------------------------------------------------}
{ G e t C o n t r o l C (break) V e c t o r }
{---------------------------------------------------------------}
Type
Arrayparam = array [1..2] of integer;
Const
SavedCtlC: arrayparam = (0,0);
NewCtlC : arrayparam = (0,0);
Procedure GetCtlC(Var SavedCtlC:arrayparam);
Begin {Record the Current Ctrl-C Vector}
With Regs Do
Begin
AX:=$3523;
MsDos(Regs);
SavedCtlC[1]:=BX;
SavedCtlC[2]:=ES;
End;
End;
{---------------------------------------------------------------}
{ S e t C o n t r o l C V e c t o r }
{---------------------------------------------------------------}
Procedure IRET; {Dummy Ctrl-C routine}
Begin
inline($5D/$5D/$CF); {Pop Bp/Pop Bp/Iret}
end;
Procedure SetCtlC(Var CtlCptr:arrayparam);
Begin {Set the New Ctrl-C Vector}
With Regs Do
Begin
AX:=$2523;
DS:=CtlCptr[2];
DX:=CtlCptr[1];
MsDos(Regs);
End;
End;
{----------------------------------------------------------------------}
{ K e y i n : R e a d K e a b o a r d }
{----------------------------------------------------------------------}
Function Keyin: char; { Get a key from the Keyboard }
Var Ch : char; { If extended key, fold above 127 }
Begin {---------------------------------------}
Repeat until Keypressed;
Read(Kbd,Ch);
if (Ch = Esc) and KeyPressed then
Begin
Read(Kbd,Ch);
Ch := Char(Ord(Ch) + 127);
End;
Keyin := Ch;
End; {Keyin}
{----------------------------------------------------------------------}
{ B e e p : S o u n d t h e H o r n }
{----------------------------------------------------------------------}
Procedure Beep(N :integer); {------------------------------------------}
Begin { This routine sounds a tone of frequency }
Sound(n); { N for approximately 100 ms }
Delay(100); {------------------------------------------}
Sound(n div 2);
Delay(100);
Nosound;
End {Beep} ;
{--------------------------------------------------------------}
{ I N T E R R U P T 2 4 }
{--------------------------------------------------------------}
{ Version 2.0, 1/28/86
- Bela Lubkin
CompuServe 76703,3015
Apologetically mangle